using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace M13.Utility.Debugger
{
    public class DebugUtil
    {
        /// <summary> ����Bounds���� </summary>
        /// <param name="bounds"></param>
        /// <param name="color"></param>
        /// <param name="offsetSize"></param>
        public static void DrawBoundBoxLine(Bounds bounds, Color color = default(Color), float offsetSize = 1f)
        {
            //�ȼ������Χ��8����
            Vector3[] points = new Vector3[8];
            var widthX = bounds.size.x * offsetSize;
            var hightY = bounds.size.y * offsetSize;
            var lengthZ = bounds.size.z * offsetSize;

            var leftBottomPoint = bounds.min;
            var rightUpPoint = bounds.max;
            var centerPoint = bounds.center;
            var topPoint = new Vector3(centerPoint.x, centerPoint.y + hightY / 2, centerPoint.z);
            var bottomPoint = new Vector3(centerPoint.x, centerPoint.y - hightY * 0.5f, centerPoint.z);

            points[0] = leftBottomPoint + Vector3.right * widthX;
            points[1] = leftBottomPoint + Vector3.up * hightY;
            points[2] = leftBottomPoint + Vector3.forward * lengthZ;

            points[3] = rightUpPoint - Vector3.right * widthX;
            points[4] = rightUpPoint - Vector3.up * hightY;
            points[5] = rightUpPoint - Vector3.forward * lengthZ;

            points[6] = leftBottomPoint;
            points[7] = rightUpPoint;

            Debug.DrawLine(leftBottomPoint, points[0], color);
            Debug.DrawLine(leftBottomPoint, points[1], color);
            Debug.DrawLine(leftBottomPoint, points[2], color);

            Debug.DrawLine(rightUpPoint, points[3], color);
            Debug.DrawLine(rightUpPoint, points[4], color);
            Debug.DrawLine(rightUpPoint, points[5], color);

            Debug.DrawLine(points[1], points[3], color);
            Debug.DrawLine(points[2], points[4], color);
            Debug.DrawLine(points[0], points[5], color);

            Debug.DrawLine(points[2], points[3], color);
            Debug.DrawLine(points[0], points[4], color);
            Debug.DrawLine(points[1], points[5], color);
        }

        public static void DrawChunkGrid(Vector2Int chunkLocalCoord, Color color)
        {
            Debug.DrawLine(new Vector3(chunkLocalCoord.x * 16, 0, chunkLocalCoord.y * 16), new Vector3(chunkLocalCoord.x * 16 + 16, 0, chunkLocalCoord.y * 16), color);
            Debug.DrawLine(new Vector3(chunkLocalCoord.x * 16, 0, chunkLocalCoord.y * 16), new Vector3(chunkLocalCoord.x * 16, 16, chunkLocalCoord.y * 16), color);
            Debug.DrawLine(new Vector3(chunkLocalCoord.x * 16, 0, chunkLocalCoord.y * 16), new Vector3(chunkLocalCoord.x * 16, 0, chunkLocalCoord.y * 16 + 16), color);
            Debug.DrawLine(new Vector3(chunkLocalCoord.x * 16, 16, chunkLocalCoord.y * 16), new Vector3(chunkLocalCoord.x * 16, 0, chunkLocalCoord.y * 16 + 16), color);
            Debug.DrawLine(new Vector3(chunkLocalCoord.x * 16, 16, chunkLocalCoord.y * 16), new Vector3(chunkLocalCoord.x * 16 + 16, 0, chunkLocalCoord.y * 16), color);

        }
    }
}